package com.im.chat.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.im.chat.model.ChatRecord;
import com.im.chat.util.DateFormat;
import com.im.chat.util.EmojiUtil;
import com.im.chat.util.biz.ImagePropertiesConfig;
import com.sun.imageio.plugins.common.ImageUtil;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


public class ChatRecordDto {

    private Long chatmsgId;

    private String msgUniqueCode;

    private String content;

    private Integer sendType;

    private Integer isRead;

    private Integer contentType;

    private String createTime;

    public static ChatRecordDto transDto(
            ChatRecord chatRecord) {
        ChatRecordDto chatRecordDto = null;
        if (null != chatRecord) {
            chatRecordDto = new ChatRecordDto(
                    chatRecord.getId(),chatRecord.getMsgUniqueCode(),
                    EmojiUtil.transEmoji(chatRecord.getContent(),ImagePropertiesConfig.EMOJI_SERVER_PATH), chatRecord.getSendType(),
                    chatRecord.getIsRead(),chatRecord.getContentType(), DateFormat.dateToString(chatRecord.getCreateTime()));
        }
        return chatRecordDto;
    }
    public static List<ChatRecordDto> transDtos(
            List<ChatRecord> chatRecords) {
        List<ChatRecordDto> chatRecordDtoList = new ArrayList<ChatRecordDto>();
        for(ChatRecord workerPersonUnion:chatRecords){
            ChatRecordDto temp = transDto(workerPersonUnion);
            if(null!=temp){
                chatRecordDtoList.add(temp);
            }
        }
        return chatRecordDtoList;
    }

    public ChatRecordDto() {
    }

    public ChatRecordDto(Long chatmsgId, String msgUniqueCode, String content, Integer sendType, Integer isRead, Integer contentType, String createTime) {
        this.chatmsgId = chatmsgId;
        this.msgUniqueCode = msgUniqueCode;
        this.content = content;
        this.sendType = sendType;
        this.isRead = isRead;
        this.contentType = contentType;
        this.createTime = createTime;
    }
    public Long getChatmsgId() {
        return chatmsgId;
    }

    public void setChatmsgId(Long chatmsgId) {
        this.chatmsgId = chatmsgId;
    }

    public String getMsgUniqueCode() {
        return msgUniqueCode;
    }

    public void setMsgUniqueCode(String msgUniqueCode) {
        this.msgUniqueCode = msgUniqueCode;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getSendType() {
        return sendType;
    }

    public void setSendType(Integer sendType) {
        this.sendType = sendType;
    }

    public Integer getIsRead() {
        return isRead;
    }

    public void setIsRead(Integer isRead) {
        this.isRead = isRead;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public Integer getContentType() {
        return contentType;
    }

    public void setContentType(Integer contentType) {
        this.contentType = contentType;
    }
}
